package com.quan.amqp.listener;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.quan.common.base.constant.CommonConstant;
import com.quan.sdk.oss.qiniu.QiniuOSSUtils;
import com.quan.system.entity.SystemOss;

/**
 * RabbitMQ 主题模式
 * @author yhaoquan
 *
 */
@Component
@RabbitListener(queues = CommonConstant.MQ_TOPIC_MESSAGE_OSS_DELETE)
public class TopicMessageOssDeleteListener {
	
	private Logger logger = LoggerFactory.getLogger(getClass()) ;
	
	@Autowired
	private QiniuOSSUtils qiniuOSSUtils;
	
	@RabbitHandler
	public void processMessage(List<SystemOss> listOss) {
		logger.info("处理Topic队列消息==>>删除OSS云服务器上的文件>>>>>>>>");
		for (SystemOss systemOss : listOss) {
			this.qiniuOSSUtils.delete(systemOss.getBucketName(), systemOss.getFileName()) ;
		}
	}

}
